import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:grocery_app_demo/pages/about/view.dart';
import 'package:grocery_app_demo/pages/login/view.dart';
import 'package:grocery_app_demo/pages/purchase_main/purchase_create/view.dart';
import 'package:grocery_app_demo/pages/purchase_main/view.dart';
import 'package:grocery_app_demo/pages/purchase_main/wait_for_purchase_orders/view.dart';
import 'package:grocery_app_demo/pages/select_goods/view.dart';
import 'package:grocery_app_demo/pages/setting/view.dart';
import 'package:grocery_app_demo/pages/splash/view.dart';
import 'package:grocery_app_demo/routes/auth_middleware.dart';

class AppRoutes {
  static const String initialRoute = '/initialRoute';
  static const String loginPage = '/login';
  static const String aboutPage = '/about';
  static const String settingPage = '/setting';
  static const String purchase = '/purchase';
  static const String createPurchase = '/createPurchase';
  static const String selectGoods = '/selectGoods';
  static const String waitForPurchaseGoods = '/waitForPurchaseGoods';

  static List<GetPage> pages = [
    buildAuthPage(AppRoutes.aboutPage, const AboutView()),
    buildAuthPage(AppRoutes.settingPage, const SettingPage()),
    buildAuthPage(AppRoutes.purchase, const PurchaseMainPage()),
    buildAuthPage(AppRoutes.createPurchase, const CreatePurchasePage()),
    buildAuthPage(AppRoutes.selectGoods, const SelectGoodsPage()),
    buildAuthPage(
        AppRoutes.waitForPurchaseGoods, const WaitForPurchaseOrdersPage()),
    GetPage(
      name: initialRoute,
      page: () => const SplashScreen(),
    ),
    GetPage(
      name: loginPage,
      page: () => LoginView(),
    ),
  ];
}

GetPage buildAuthPage(String name, Widget page) {
  return GetPage(name: name, page: () => page, middlewares: [AuthMiddleware()]);
}
